 {

        var o = require("./PlayerModel.js"), i = require("../UIManager/UISoundManager.js"), a = function () {
        };
        a.prototype = {
            ctor: function () {
                this._isInGameScene = !1, this._gameId = 0, this._roomId = 0, this._tableId = 0,
                    this._action_id = 0, this._maxSeatN = 0, this._header_seat_id = 0, this._room_level = "",
                    this._room_coefficient = 0, this._no_drop_card_count = 0, this._base_chip = 0, this._reconnect = !1,
                    this._seatId = 0, this._quan_men_feng = 0, this._tableType = "normal", this._gameRule = "classic",
                    this._play_mode = "xueliu", this._room_name = "免费场", this._current_player_seat_id = 0,
                    this._min_coin = 0, this._max_coin = 0, this._play_timeout = 0, this._table_state = "play",
                    this._big_degree_fee = [], this._remained_count = 108, this._chat_chip = 0, this._chat_time = 0,
                    this._protectValue = 0, this._laizi_tiles = {}, this._paramsOptionInfo = [], this._tableTileWall = {},
                    this._players = [], this._userId = 0, this._lockPlay = !0, this._changeTileCount = 0,
                    this._scoreChange = [], this._isGameStart = !1, this._isGameEnd = !1, this.isShowTotalResult = !1,
                    this.sumUpCalculationResult = {}, this._scoreArr = [], this._createTableExtendInfo = {},
                    this.reset(), this._needInsertTileAction = !0, this.isInHuanPai = !1, this.hasGameSetGameId = {},
                    this._setLuckRedPacket(), this.init();
            },
            reset: function () {
                for (var e in this._playerModel) {
                    this._playerModel[e].onDestroy();
                }
                this._playerModel = [], this._curCount = 0, this._totalCount = 0, this._points = [1, 1],
                    this._selectHuanPaiColor = null, this._isGameStart = !1, this._isGameEnd = !1, this._needInsertTileAction = !0,
                    this.isShowTotalResult = !1, this.sumUpCalculationResult = {}, this._isAbsenced = !1,
                    this._isFirstTile = !0, this._scoreChange = [], this._isShowLuckyTile = !1, this._isTileUp = !1,
                    this._isClickContinue = !1, Global.tableModel.getTableType() == Global.config.tableType.CREATE && this._createTableExtendInfo && this.getCurrentNumberOfGames() < this.getTotalOfGames() - 1 || (this._scoreArr = [],
                    this._createTableExtendInfo = {});
            },
            init: function (e) {
                var t = null == e;
                if (this.reset(), null != e) {
                    this._gameId = e.gameId || 0, this._roomId = e.roomId || 0, this._tableId = e.tableId || 0,
                        this._action_id = e.action_id || 0, this._maxSeatN = e.maxSeatN || 0, this._header_seat_id = e.header_seat_id || 0,
                        this._room_level = e.room_level || "free", this._room_coefficient = e.room_coefficient || 0,
                        this._base_chip = e.base_chip || 0, this._reconnect = e.reconnect || !1, this._seatId = e.seatId || 0,
                        this._quan_men_feng = e.quan_men_feng || 0, this._tableType = e.tableType || "normal",
                        this._gameRule = e.gameRule || "classic", this._play_mode = e.play_mode || Global.playModel.XUELIU,
                        this._room_name = e.room_name || "", this._current_player_seat_id = e.current_player_seat_id || 0,
                        this._min_coin = e.min_coin || 0, this._max_coin = e.max_coin || 0, this._table_state = e.table_state || Global.config.playState.WAITING,
                        this._play_timeout = e.play_timeout || 0, this._big_degree_fee = e.big_degree_fee || [],
                        this._remained_count = e.remained_count || 0, this._chat_chip = e.chat_chip || 0,
                        this._chat_time = e.chat_time || 0, this._protectValue = e.protectValue || 0, this._laizi_tiles = e.laizi_tiles || {},
                        this._paramsOptionInfo = e.paramsOptionInfo || [], this._tableTileWall = e.tableTileWall || {},
                        this._players = e.players || [], this._userId = e.userId || 0, this._changeTileCount = e.changeTileCount || 0,
                        this._createTableExtendInfo = e.create_table_extend_info || {}, this._scoreArr = 0 == this.getCurrentNumberOfGames() ? [] : this._scoreArr,
                        Global.SetGameId(this._gameId), Global.roomInfoModel.setPlayModel(this._play_mode),
                        Global.roomInfoModel.setRoomId(this._roomId);
                    var n = 0;
                    if (Global.roomInfoModel.getPlayModel() != Global.config.playModel.ERREN && Global.roomInfoModel.getPlayModel() != Global.config.playModel.ERRENQUICK || (n = 1),
                        i.setSoundType(n), this.updatePlayerModel(), 0 == t) {
                        var o = [];
                        this._players.forEach(function (e) {
                            o.push(e.state);
                        });
                        var a = !1;
                        Global.tableModel.getTableType() == Global.config.tableType.CREATE && (a = !0);
                        var r = this._players.length < this._maxSeatN || o.indexOf(Global.config.playState.SIT) > 0;
                        if (console.log(" this._players.length < this._maxSeatN || playerState.indexOf(Global.config.playState.PLAY) == -1:", o, this._players.length, this._maxSeatN, this.getIsGameEnd(), o.indexOf(Global.config.playState.SIT), r),
                            r) if (SceneHelper.loadScene("waittingScene"), a) {
                            var s = Global.config.QueryTag.inviteToFriRoom;
                            Global.query && Global.query.extraInfo && Global.query.extraInfo[s] && (Global.query.extraInfo[s] = null,
                                console.log("+++++++++++++inviteToFriRoom+++++++++++++++，", s, Global.query.extraInfo)),
                                tywx.BiLog.clickStat(tywx.clickStatEventType.clickStatEventType_ENTER_FRI_ROOM, []);
                            for (var l = 0; l < o.length; l++) o[l] == Global.config.playState.SIT && 0 != this.getCurrentNumberOfGames() && Global.msgHandler.requestNextRound(Global.tableModel.getRoomId(), Global.tableModel.getTableId(), this._players[l].seatId);
                        } else tywx.BiLog.clickStat(tywx.clickStatEventType.clickStatEventType_ENTER_ROOM, []); else this._isGameStart = !0,
                            function () {
                                Global.notificationCenter.stop();
                                SceneHelper.loadScene("gameScene", function () {
                                    Global.notificationCenter.start(), Global.notificationCenter.emit(Global.eventName.GAME_REFRESH_STAND_TILE);
                                });
                            }();
                    }
                } else cc.error("TableModel init tableInfo == null");
            },
            updatePlayerModel: function () {
                for (var e = 0; e < this._players.length; e++) {
                    var t = this._players[e], n = this.toLocalSeatIndex(t.seatId), i = this._playerModel[n];
                    null == i && ((i = new o()).ctor(), this._playerModel[n] = i), this._scoreArr && this._scoreArr[e] && i.updateFriScore(this._scoreArr[e]),
                        i.updatePlayerInfo(t);
                }
            },
            playerSit: function (e) {
                var t = this.toLocalSeatIndex(e.seatId), n = this.getPlayerModel(t);
                null == n ? ((n = new o()).ctor(), n.playerSit(e), this._playerModel[t] = n) : n.setState(e.state);
            },
            doCrapShoot: function () {
                cc.log("===========onCrapShoot  掷骰子 doCrapShoot================="), Global.notificationCenter.emit(Global.eventName.GAME_CRAPSHOOT, this._points);
            },
            tableCall: function (e) {
                if ("ready" == e.action) {
                    var t = this.toLocalSeatIndex(e.seatId);
                    null != (l = this.getPlayerModel(t)) && l.setReady(), Global.notificationCenter.emit(Global.eventName.GAME_SHOW_ISREADY, e);
                } else if ("crapshoot" == e.action) this._points = e.points; else if ("ask_huanPai" == e.action) {
                    if (0 == this.isInGameScene()) return void cc.error("TableModel ask_huanPai not in gameScene");
                    if (Global.notificationCenter.emit(Global.eventName.GAME_SHOW_TIMER, !0), Global.notificationCenter.emit(Global.eventName.GAME_DESTROY_CRAPSHOOT),
                        this._action_id = e.action_id, Global.notificationCenter.emit(Global.eventName.GAME_SHOW_ASKHUANPAI),
                        Global.notificationCenter.emit(Global.eventName.GAME_ASK_HUANPAI, e), this.isInHuanPai = !0,
                        Global.notificationCenter.emit(Global.eventName.GAME_HUANPAI_UNSELECT_ALL), l = Global.tableModel.getPlayerModel(Global.config.SEAT_DOWN)) {
                        for (var n = l.getStandup_tiles(), o = [], i = 0; i < e.tiles.length; i++) for (var a = e.tiles[i], r = 0; r < n.length; r++) {
                            var s = r;
                            if (a == n[r] && o.indexOf(s) < 0) {
                                o.push(s);
                                break;
                            }
                        }
                        Global.notificationCenter.emit(Global.eventName.MSG_SET_HUANPAI_STAND_TILE, {
                            upIndexs: o
                        });
                    }
                    this.updateTimeOut(e);
                } else if ("accept_huanPai" == e.action) {
                    if (0 == this.isInGameScene()) return void cc.error("TableModel accept_huanPai not in gameScene");
                    var l;
                    if (this._action_id = e.action_id, this.toLocalSeatIndex(e.seatId) == Global.config.SEAT_DOWN && null != e.tiles) (l = this.getPlayerModel(Global.config.SEAT_DOWN)) && l.updateTiles(e.tiles);
                    if (Global.notificationCenter.emit(Global.eventName.GAME_ACCEPT_HUANPAI, e), this.isInHuanPai = !1,
                        Global.notificationCenter.emit(Global.eventName.GAME_REFRESH_STAND_TILE), l) {
                        for (n = l.getStandup_tiles(), o = [], i = 0; i < e.afterTiles.length; i++) for (a = e.afterTiles[i],
                                                                                                             r = 0; r < n.length; r++) {
                            s = r;
                            if (a == n[r] && o.indexOf(s) < 0) {
                                o.push(s);
                                break;
                            }
                        }
                        Global.notificationCenter.emit(Global.eventName.GAME_PLAY_ACCEPT_HUANPAI_ANI, o);
                    }
                } else if (e.action == Global.eventName.CMD_CHARGING) {
                    this._actionId = e.action_id;
                    var c = e.seatId;
                    Global.notificationCenter.emit(Global.eventName.MSG_CHARGING, e);
                    var d = e.timeout, u = this, h = this.toLocalSeatIndex(c);
                    if (h >= 0 && h == Global.config.SEAT_DOWN) {
                        this.rechargeTimer = setInterval(function () {
                            d >= 0 ? d-- : (u.requestCharge(-1, c), u.rechargeTimer && (clearInterval(u.rechargeTimer),
                                u.rechargeTimer = null));
                        }, 1e3);
                    }
                } else e.action == Global.eventName.CMD_CHARGED ? (console.log("msgHandler CMD_CHARGED"),
                    Global.notificationCenter.emit(Global.eventName.MSG_CHARGED, e)) : "updateTingResult" == e.action && this.updateTingResult(e, "tingResult");
            },
            requestCharge: function (e, t) {
                e = void 0 == e ? -1 : e;
                var n = Global.tableModel.getRoomId(), o = Global.tableModel.getTableId(), i = e;
                void 0 != t && void 0 != this._actionId && 0 != n && 0 != o ? (Global.msgHandler.requestCharge(n, o, t, i, this._actionId),
                this.rechargeTimer && (clearInterval(this.rechargeTimer), this.rechargeTimer = null)) : console.error("requestCharge error :", e, t, this._actionId, n, o);
            },
            askAbsence: function (e) {
                0 != this.isInGameScene() ? (this._action_id = e.action_id, this.updateTimeOut(e),
                    Global.notificationCenter.emit(Global.eventName.GAME_SHOW_ABSENCE, e)) : cc.error("TableModel askAbsence not in gameScene");
            },
            notifyAbsence: function (e) {
                if (0 != this.isInGameScene()) {
                    if (this._action_id = e.action_id, this.toLocalSeatIndex(e.seatId) == Global.config.SEAT_DOWN) {
                        var t = this.getPlayerModel(Global.config.SEAT_DOWN);
                        if (t) {
                            t.setAbsenceColor(e.color);
                            var n = {
                                color: e.color,
                                seatId: e.seatId,
                                reconnect: e.reconnect
                            };
                            Global.notificationCenter.emit(Global.eventName.GAME_DO_ABSCENCE_ANI, n), Global.notificationCenter.emit(Global.eventName.MSG_FINISH_DING_QUE);
                        }
                    }
                    Global.notificationCenter.emit(Global.eventName.GAME_REFRESH_STAND_TILE), Global.notificationCenter.emit(Global.eventName.GAME_RESET_TILE_YELLOW);
                } else cc.error("TableModel notifyAbsence not in gameScene");
            },
            absenceEnd: function (e) {
                if (0 != this.isInGameScene()) {
                    this._isAbsenced = !0, this._action_id = e.action_id;
                    for (var t = this.toLocalSeatIndex(e.seatId), n = 0; n < e.color.length; n++) {
                        var o = this.toLocalSeatIndex(n);
                        if ((a = this.getPlayerModel(o)) && (a.setAbsenceColor(e.color[n]), o != Global.config.SEAT_DOWN || 1 == e.reconnect)) {
                            var i = {
                                color: e.color[n],
                                seatId: n,
                                reconnect: e.reconnect
                            };
                            Global.notificationCenter.emit(Global.eventName.GAME_DO_ABSCENCE_ANI, i);
                        }
                    }
                    var a = this.getPlayerModel(t);
                    t == Global.config.SEAT_DOWN && e.standup_tiles && (a.updateTiles(e.standup_tiles),
                    null != e.tile && a.sendTile(e.tile)), this.updateTingAction(e), Global.notificationCenter.emit(Global.eventName.GAME_REFRESH_OPRETATION, e),
                        Global.notificationCenter.emit(Global.eventName.GAME_REFRESH_STAND_TILE), Global.notificationCenter.emit(Global.eventName.GAME_RESET_TILE_YELLOW),
                        Global.notificationCenter.emit(Global.eventName.MSG_ALL_FINISH_DING_QUE), this.toLocalSeatIndex(this._header_seat_id) == Global.config.SEAT_DOWN && this.unLockPlayTile(),
                        this.unLockTouchMove();
                    var r = {
                        seatId: this._header_seat_id,
                        timeOut: e.timeOut
                    };
                    this.updateTimeOut(r);
                } else cc.error("TableModel absenceEnd not in gameScene");
            },
            tableEvent: function (e) {
                for (var t = 0; t < e.players.length; t++) {
                    var n = e.players[t], i = this.toLocalSeatIndex(n.seatId), a = this.getPlayerModel(i);
                    null == a ? ((a = new o()).ctor(), a.updatePlayerInfo(n), this._playerModel[i] = a) : a.updatePlayerInfo(n);
                }
                Global.notificationCenter.emit(Global.eventName.GAME_WAITTING_SHOWHEADDATA), Global.notificationCenter.emit(Global.eventName.MSG_JUDGE_SEAT_FULL, e);
            },
            removePlayer: function (e) {
                for (var t = 0; t < this._players.length; t++) {
                    var n = this._players[t];
                    this.toLocalSeatIndex(n.seatId) == this.toLocalSeatIndex(e.seatId) && this._players.pop(n);
                }
            },
            tableGameStart: function (e) {
                this._setLuckRedPacket(), this._curCount = e.curCount, this._totalCount = e.totalCount,
                    this._isGameStart = !0, Global.notificationCenter.emit(Global.eventName.GAME_TABLE_GAME_START);
            },
            initTiles: function (e) {
                if (0 != this.isInGameScene()) {
                    this._isAbsenced = !1, this.lockPlayTile(), this.lockTouchMove();
                    for (var t = 0; t < this._maxSeatN; t++) {
                        var n = this.getPlayerModel(t);
                        if (t == Global.config.SEAT_DOWN) n && n.updateTiles(e.tiles); else if (Global.roomInfoModel.getPlayModel() != Global.config.playModel.ERREN && Global.roomInfoModel.getPlayModel() != Global.config.playModel.ERRENQUICK || (n = this.getPlayerModel(Global.config.SEAT_UP)),
                            n) {
                            var o = [], i = 13;
                            Global.roomInfoModel.getPlayModel() == Global.config.playModel.ERRENQUICK && (i = 4);
                            for (var a = 0; a < i; a++) o.push(-1);
                            n.updateTiles(o);
                        }
                    }
                    Global.notificationCenter.emit(Global.eventName.GAME_REFRESH_STAND_TILE, {
                        isInitTile: !0
                    });
                } else cc.error("TableModel initTiles not in gameScene");
            },
            updateScore: function (e) {
                console.log("tableModel updateScore data = ", JSON.stringify(e));
                var t = Global.tableModel.getTableType();
                if (t == Global.config.tableType.CREATE || t == Global.config.tableType.SCORE_TABLE) {
                    if (console.log("tableModel updateScore 好友房 data= ", JSON.stringify(e)), e.score) {
                        for (var n = 0; n < e.score.length; n++) {
                            var o = this.toLocalSeatIndex(n);
                            (i = this.getPlayerModel(o)) && (console.log("tableModel updateScore i:", n, e.score[n]),
                                i.updateFriScore(e.score[n]));
                        }
                        this.setScoreArr(e.score);
                    }
                } else if (console.log("tableModel updateScore 金币房 data= ", JSON.stringify(e)),
                    e.tableCoin) for (n = 0; n < e.tableCoin.length; n++) {
                    var i;
                    o = this.toLocalSeatIndex(n);
                    (i = this.getPlayerModel(o)) && i.updateScore(e.tableCoin[n]);
                }
                Global.notificationCenter.emit(Global.eventName.GAME_UPDATE_SCORE, e);
            },
            sendTile: function (e) {
                if (0 != this.isInGameScene()) {
                    this._action_id = e.action_id, this._remained_count = e.remained_count;
                    var t = e.seatId, n = this.toLocalSeatIndex(t), o = this.getPlayerModel(n);
                    if (null != o) {
                        if (this.lockPlayTile(), this.updateTingAction(e), e.ting_action && e.tile) for (var i = 0; i < e.ting_action.length; i++) {
                            var a = e.ting_action[i][0];
                            if (e.tile == a) {
                                e.ting_result = e.ting_action[i][1], this.updateTingResult(e, "ting_result");
                                break;
                            }
                        }
                        if (n == Global.config.SEAT_DOWN && e.tile) o.isWin() || o.getIsTing() || Global.notificationCenter.emit(Global.eventName.GAME_SHOW_TINGTIP, !1),
                        this._isAbsenced && (this.unLockPlayTile(), this.unLockTouchMove()), Global.roomInfoModel.getPlayModel() != Global.config.playModel.ERREN && Global.roomInfoModel.getPlayModel() != Global.config.playModel.ERRENQUICK || o.getIsTing() || (this.unLockPlayTile(),
                            this.unLockTouchMove()), e.trustee && !e.reconnect ? o.setTrustee() : o.removeTrustee(),
                            o.updateTiles(e.standup_tiles), o.sendTile(e.tile), Global.notificationCenter.emit(Global.eventName.GAME_REFRESH_OPRETATION, e); else {
                            o.sendTile(-1), Global.notificationCenter.emit(Global.eventName.GAME_CLEAR_OPERTATION);
                            var r = this.getPlayerModel(Global.config.SEAT_DOWN);
                            n != Global.config.SEAT_DOWN && r.getTingResult().length > 0 && Global.notificationCenter.emit(Global.eventName.GAME_SHOW_TINGTIP, !0);
                        }
                        Global.notificationCenter.emit(Global.eventName.GAME_REFRESH_REMAIN_COUNT);
                        var s = {
                            needSendTileAction: !0,
                            refreshSeatId: n
                        };
                        Global.notificationCenter.emit(Global.eventName.GAME_REFRESH_STAND_TILE, s), Global.tableModel.resetIsNeedTileAction(!0),
                        n == Global.config.SEAT_DOWN && Global.notificationCenter.emit(Global.eventName.GAME_RESET_TILE_YELLOW),
                        this._isFirstTile && 1 != this.isReconnect() && (this._isFirstTile = !1, console.log("showZhuangjiaTip sendTile seatid:", t),
                            Global.notificationCenter.emit(Global.eventName.MSG_SHOWZHUANGJIATIP, !0)), this.updateTimeOut(e);
                    } else cc.error("TableModel sendTile playerModel = null");
                } else cc.error("TableModel sendTile not in gameScene");
            },
            playTile: function (e) {
                if (0 != this.isInGameScene()) if (null != e) {
                    i.playCrashEffect(), this.lockPlayTile(), this._action_id = e.action_id, this._remained_count = e.remained_count;
                    var t = this.toLocalSeatIndex(e.seatId), n = this.getPlayerModel(t);
                    n && n.playTile(e), this.updateTingAction(e), this.updateTingResult(e, "ting_result"),
                        Global.notificationCenter.emit(Global.eventName.GAME_REFRESH_OPRETATION, e);
                    var o = {
                        seatId: t,
                        refreshSeatId: t
                    };
                    t == Global.config.SEAT_DOWN && n && 1 != n.isWin() && 1 != this.isTrustee() && (o = null,
                        o = {
                            needRefresh: !1,
                            refreshSeatId: t
                        }), Global.notificationCenter.emit(Global.eventName.GAME_REFRESH_STAND_TILE, o),
                    t == Global.config.SEAT_DOWN && (Global.notificationCenter.emit(Global.eventName.GAME_SHOW_TING_ACTION, null),
                        Global.notificationCenter.emit(Global.eventName.GAME_RESET_TILE_YELLOW)), Global.notificationCenter.emit(Global.eventName.MSG_SHOWZHUANGJIATIP, !1),
                        Global.notificationCenter.emit(Global.eventName.GAME_SET_TINGGRAY_STANDTILE, !1);
                } else cc.error("TableModel playTile data = null"); else cc.error("TableModel playTile not in gameScene");
            },
            grabGangHu: function (e) {
                0 != this.isInGameScene() ? (this._action_id = e.action_id, Global.notificationCenter.emit(Global.eventName.GAME_REFRESH_OPRETATION, e),
                    this.updateTimeOut(e)) : cc.error("TableModel peng not in gameScene");
            },
            peng: function (e) {
                if (0 != this.isInGameScene()) {
                    this._action_id = e.action_id, this.toLocalSeatIndex(e.seatId) == Global.config.SEAT_DOWN && (this._needInsertTileAction = !1);
                    var t = this.getPlayerModel(this.toLocalSeatIndex(e.seatId));
                    t && t.peng(e, !0);
                    var n = this.getPlayerModel(this.toLocalSeatIndex(e.player_seat_id));
                    n && n.peng(e, !1), this.updateTingAction(e), Global.notificationCenter.emit(Global.eventName.GAME_DES_BIGPLAYEDTILE),
                        Global.notificationCenter.emit(Global.eventName.GAME_REFRESH_OPRETATION, e), e.reconnect || Global.notificationCenter.emit(Global.eventName.GAME_PLAY_EFFECT_PENG, e),
                        Global.notificationCenter.emit(Global.eventName.GAME_REFRESH_STAND_TILE), Global.notificationCenter.emit(Global.eventName.GAME_RESET_TILE_YELLOW),
                        this.updateTimeOut(e);
                } else cc.error("TableModel peng not in gameScene");
            },
            chi: function (e) {
                if (0 != this.isInGameScene()) {
                    this._action_id = e.action_id, this.toLocalSeatIndex(e.seatId) == Global.config.SEAT_DOWN && (this._needInsertTileAction = !1);
                    var t = this.getPlayerModel(this.toLocalSeatIndex(e.seatId));
                    t && t.chi(e, !0);
                    var n = this.getPlayerModel(this.toLocalSeatIndex(e.player_seat_id));
                    n && n.chi(e, !1), this.updateTingAction(e), Global.notificationCenter.emit(Global.eventName.GAME_DES_BIGPLAYEDTILE),
                        Global.notificationCenter.emit(Global.eventName.GAME_REFRESH_OPRETATION, e), e.reconnect || Global.notificationCenter.emit(Global.eventName.GAME_PLAY_EFFECT_CHI, e),
                        Global.notificationCenter.emit(Global.eventName.GAME_REFRESH_STAND_TILE), Global.notificationCenter.emit(Global.eventName.GAME_RESET_TILE_YELLOW),
                        this.updateTimeOut(e);
                } else cc.error("TableModel peng not in gameScene");
            },
            ting: function (e) {
                if (0 != this.isInGameScene()) {
                    var t = this.toLocalSeatIndex(e.seatId), n = this.getPlayerModel(t);
                    n && n.ting(e), this.updateTingAction(e), Global.notificationCenter.emit(Global.eventName.GAME_DES_BIGPLAYEDTILE),
                    t == Global.config.SEAT_DOWN && Global.notificationCenter.emit(Global.eventName.GAME_CLEAR_OPERTATION),
                    e.reconnect || Global.notificationCenter.emit(Global.eventName.GAME_PLAY_EFFECT_TING, e),
                        Global.notificationCenter.emit(Global.eventName.GAME_REFRESH_STAND_TILE), Global.notificationCenter.emit(Global.eventName.GAME_RESET_TILE_YELLOW),
                        this.updateTimeOut(e);
                } else cc.error("TableModel peng not in gameScene");
            },
            gang: function (e) {
                if (0 != this.isInGameScene()) {
                    var t;
                    if (this._action_id = e.action_id, (t = this.getPlayerModel(this.toLocalSeatIndex(e.seatId))) && t.gang(e, !0),
                    null != e.player_seat_id) (t = this.getPlayerModel(this.toLocalSeatIndex(e.player_seat_id))) && t.gang(e, !1);
                    if (this.lockPlayTile(), this.updateTimeOut(e), this.updateTingAction(e), Global.notificationCenter.emit(Global.eventName.GAME_DES_BIGPLAYEDTILE),
                        Global.notificationCenter.emit(Global.eventName.GAME_CLEAR_OPERTATION), !e.reconnect) {
                        Global.notificationCenter.emit(Global.eventName.GAME_PLAY_EFFECT_GANG, e);
                        var n = [];
                        if (e.detailChangeScores) for (var o = 0; o < e.detailChangeScores.length; ++o) n.push(e.detailChangeScores[o].gangScore);
                        e.seatId;
                        this.onScoreChangeData(e, 1);
                    }
                    Global.notificationCenter.emit(Global.eventName.GAME_REFRESH_STAND_TILE), Global.notificationCenter.emit(Global.eventName.GAME_RESET_TILE_YELLOW);
                } else cc.error("TableModel gang not in gameScene");
            },
            win: function (e) {
                if (0 != this.isInGameScene()) {
                    if ((o = this.getPlayerModel(this.toLocalSeatIndex(e.seatId))) && o.win(e), Global.notificationCenter.emit(Global.eventName.GAME_CLEAR_OPERTATION),
                        Global.notificationCenter.emit(Global.eventName.GAME_PLAY_EFFECT_HU, e), Global.roomInfoModel.getPlayModel() == Global.config.playModel.ERRENQUICK) {
                        var t = e.tilesInfo;
                        o && o.updateTiles(t.tiles);
                    }
                    var n, o;
                    if (n = {
                        winloseSeatId: e.seatId,
                        isDelTile: !1,
                        refreshSeatId: e.seatId
                    }, Global.notificationCenter.emit(Global.eventName.GAME_DES_BIGPLAYEDTILE), Global.notificationCenter.emit(Global.eventName.GAME_REFRESH_STAND_TILE, n),
                        Global.notificationCenter.emit(Global.eventName.GAME_RESET_TILE_YELLOW), e.reconnect || this.onScoreChangeData(e, this._maxSeatN),
                        e.isGameEnd) {
                        var i = {
                            timeOut: -1,
                            curSeatId: e.seatId
                        };
                        Global.notificationCenter.emit(Global.eventName.GAME_UPDATA_TIME_OUT, i);
                    }
                    !(o = this.getPlayerModel(Global.config.SEAT_DOWN)) || o.getSeatId() != e.seatId || Global.roomInfoModel.getPlayModel() != Global.config.playModel.ERREN && Global.roomInfoModel.getPlayModel() != Global.config.playModel.ERRENQUICK || o.detailInfo({
                        detailDescList: e.detail.patterns
                    }), Global.notificationCenter.emit(Global.eventName.MSG_TING, {
                        isGameEnd: e.isGameEnd
                    });
                } else cc.error("TableModel win not in gameScene");
            },
            lose: function (e) {
                if (0 != this.isInGameScene()) {
                    if ((n = this.getPlayerModel(this.toLocalSeatIndex(e.seatId))) && n.lose(e), Global.notificationCenter.emit(Global.eventName.GAME_CLEAR_OPERTATION),
                    Global.roomInfoModel.getPlayModel() == Global.config.playModel.ERRENQUICK) {
                        var t = e.tilesInfo;
                        n && n.updateTiles(t.tiles);
                    }
                    var n, o = null;
                    o = e.winMode < 0 && e.winMode != Global.config.winMode.Lose ? {
                        winloseSeatId: e.seatId,
                        isDelTile: !0,
                        refreshSeatId: e.seatId
                    } : {
                        winloseSeatId: e.seatId,
                        isDelTile: !1,
                        refreshSeatId: e.seatId
                    }, Global.notificationCenter.emit(Global.eventName.GAME_DES_BIGPLAYEDTILE), Global.notificationCenter.emit(Global.eventName.GAME_REFRESH_STAND_TILE, o),
                        Global.notificationCenter.emit(Global.eventName.GAME_RESET_TILE_YELLOW), e.reconnect || this.onScoreChangeData(e, this._maxSeatN),
                    !(n = this.getPlayerModel(Global.config.SEAT_DOWN)) || n.getSeatId() != e.seatId || Global.roomInfoModel.getPlayModel() != Global.config.playModel.ERREN && Global.roomInfoModel.getPlayModel() != Global.config.playModel.ERRENQUICK || n.detailInfo({
                        detailDescList: e.detail.patterns
                    });
                } else cc.error("TableModel lose not in gameScene");
            },
            onScoreChangeData: function (e, t) {
                var n = {
                    detailChangeScores: e.detailChangeScores,
                    seatId: e.seatId
                };
                if (this._scoreChange.push(n), this._scoreChange.length >= t) {
                    var o = !1;
                    null != e.isGameEnd && (o = e.isGameEnd), Global.notificationCenter.emit(Global.eventName.GAME_DETAIL_CHANGE_SCORES, {
                        changeData: this._scoreChange,
                        isGameEnd: o
                    }), this._scoreChange = [];
                }
            },
            detailInfo: function (e) {
                console.log("detailinfo === ", e);
                var t = this.getPlayerModel(this.toLocalSeatIndex(e.seatId));
                t && t.detailInfo(e), Global.notificationCenter.emit(Global.eventName.MSG_SCORE_DATA, e);
            },
            totalResult: function (e) {
                this.sumUpCalculationResult = e, this.isShowTotalResult = !0, this._isGameEnd = !0,
                    this._isGameStart = !1;
            },
            roundResult: function (e) {
                if (this._isGameEnd = !0, this._isGameStart = !1, 0 != this.isInGameScene()) {
                    for (var t = 0; t < e.infos.length; t++) {
                        var n = e.infos[t], o = this.getPlayerModel(this.toLocalSeatIndex(n.seatId));
                        o && (o.updateTiles(n.tilesInfo.tiles), o.updatePengTiles(n.tilesInfo.peng), o.updateChiTiles(n.tilesInfo.chi),
                            o.updateGangTiles(n.tilesInfo.gang));
                    }
                    Global.notificationCenter.emit(Global.eventName.GAME_DES_TILE_TEMTILE), Global.notificationCenter.emit(Global.eventName.GAME_REFRESH_STAND_TILE),
                        Global.notificationCenter.emit(Global.eventName.GAME_SHOW_RESULT, e), Global.notificationCenter.emit(Global.eventName.MSG_DES_LUCKY_TILES);
                } else cc.error("TableModel roundResult not in gameScene");
            },
            updateTimeOut: function (e) {
                if (0 != this.isInGameScene()) {
                    var t = 0, n = e.seatId;
                    null == e && (t = 0, n = -1), null != e.timeout && (t = e.timeout), null != e.timeOut && (t = e.timeOut);
                    var o = {
                        timeOut: t,
                        curSeatId: n
                    };
                    t > 0 && Global.notificationCenter.emit(Global.eventName.GAME_UPDATA_TIME_OUT, o);
                } else cc.error("TableModel updateTimeOut not in gameScene");
            },
            updateTingAction: function (e) {
                if (0 != this.isInGameScene()) {
                    if (this.toLocalSeatIndex(e.seatId) == Global.config.SEAT_DOWN) {
                        var t = this.getPlayerModel(Global.config.SEAT_DOWN);
                        null != e.ting_action && e.ting_action.length > 0 ? t && t.setTingActions(e.ting_action) : null != e.grabTing && e.grabTing.length > 0 ? t && t.setTingActions(e.grabTing) : t && t.setTingActions(null);
                    }
                } else cc.error("TableModel updateTingAction not in gameScene");
            },
            updateTingResult: function (e, t) {
                if (0 != this.isInGameScene()) {
                    var n = this.getPlayerModel(Global.config.SEAT_DOWN);
                    null != e[t] && e[t].length > 0 ? n && n.setTingResult(e[t]) : n && n.setTingResult(null);
                    var o = Global.tableModel.getPlayerModel(Global.config.SEAT_DOWN);
                    if (o) {
                        var i = o.getTingResult();
                        Global.notificationCenter.emit(Global.eventName.GAME_UPDATE_TING_ACTION, i);
                    }
                } else cc.error("TableModel updateTingResult not in gameScene");
            },
            onSetTrustee: function (e) {
                var t = this.getPlayerModel(this.toLocalSeatIndex(e.seatId));
                t && t.setTrustee(e);
            },
            onRemoveTrustee: function (e) {
                var t = this.toLocalSeatIndex(e.seatId), n = this.getPlayerModel(t);
                n && n.removeTrustee();
            },
            toLocalSeatIndex: function (e) {
                if (this._maxSeatN < 1) return cc.error("toLocalSeatIndex error this._maxSeatN = " + this._maxSeatN),
                    0;
                var t = (e - this._seatId + this._maxSeatN) % this._maxSeatN;
                return Global.roomInfoModel.getPlayModel() != Global.config.playModel.ERREN && Global.roomInfoModel.getPlayModel() != Global.config.playModel.ERRENQUICK || this._seatId !== e && (t = Global.config.SEAT_UP),
                    t;
            },
            _getMyPlayer: function () {
                for (var e = null, t = this.getPlayers(), n = 0, o = t.length; n < o; ++n) if ((e = t[n]) && e.userId == Global.userProfile.getUserId()) return e;
                return e;
            },
            localPlayerIsHeader: function () {
                return this.getPlayerModel(Global.config.SEAT_DOWN).getSeatId() == this.getHeadSeat();
            },
            isReconnect: function () {
                return this._reconnect;
            },
            getTableType: function () {
                return this._tableType;
            },
            getPlayerModel: function (e) {
                var t = this._playerModel[e];
                if (null != t) return t;
            },
            getPlayerModelByUserId: function (e) {
                for (var t = null, n = 0; n < this._playerModel.length; n++) if ((t = this._playerModel[n]) && t.getUserId() == e) return t;
                return t;
            },
            resetIsNeedTileAction: function (e) {
                this._needInsertTileAction = e;
            },
            getIsNeedTileAction: function () {
                return this._needInsertTileAction;
            },
            getPlayerModels: function () {
                return this._playerModel;
            },
            getCreateTableNo: function () {
                return this._createTableExtendInfo.create_table_no;
            },
            getCreateTableDescList: function () {
                return this._createTableExtendInfo.create_table_desc_list;
            },
            getCurrentNumberOfGames: function () {
                return this._createTableExtendInfo.create_now_cardcount;
            },
            getTotalOfGames: function () {
                return this._createTableExtendInfo.create_total_cardcount;
            },
            getCurrentCount: function () {
                return this._createTableExtendInfo.currentProgress;
            },
            getHostUserId: function () {
                return this._createTableExtendInfo.hostUserId;
            },
            getGameId: function () {
                return this._gameId;
            },
            getRoomId: function () {
                return this._roomId;
            },
            getTableId: function () {
                return this._tableId;
            },
            getSeatId: function () {
                return this._seatId;
            },
            getRemainCount: function () {
                return this._remained_count;
            },
            getPoints: function () {
                return this._points;
            },
            isTrustee: function () {
                var e = this.getPlayerModel(Global.config.SEAT_DOWN);
                return !!e && e.getTrustee();
            },
            isTing: function () {
                var e = this.getPlayerModel(Global.config.SEAT_DOWN);
                return !!e && e.getIsTing();
            },
            getActionId: function () {
                return this._action_id;
            },
            lockPlayTile: function () {
                this._lockPlay = !0;
            },
            unLockPlayTile: function () {
                this._lockPlay = !1;
            },
            isLockPlayTile: function () {
                return this._lockPlay;
            },
            lockTouchMove: function () {
                this._isLockTouchMove = !0;
            },
            unLockTouchMove: function () {
                this._isLockTouchMove = !1;
            },
            isLockTouchMove: function () {
                return this._isLockTouchMove;
            },
            getChangeTileCount: function () {
                return this._changeTileCount;
            },
            setSelectHuanPaiColor: function (e) {
                this._selectHuanPaiColor = e;
            },
            getSelectHuanPaiColor: function () {
                return this._selectHuanPaiColor;
            },
            getHeadSeat: function () {
                return this._header_seat_id;
            },
            getMaxSeat: function () {
                return this._maxSeatN;
            },
            getIsGameStart: function () {
                return this._isGameStart;
            },
            getIsGameEnd: function () {
                return this._isGameEnd;
            },
            getIsShowTotalResult: function () {
                return this.isShowTotalResult;
            },
            getTotalResult: function () {
                return this.sumUpCalculationResult;
            },
            setInGameScene: function (e) {
                this._isInGameScene = e || !1;
            },
            isInGameScene: function () {
                return this._isInGameScene;
            },
            getUserId: function () {
                return this._userId;
            },
            getPlayMode: function () {
                return this._play_mode;
            },
            getBaseChip: function () {
                return this._base_chip;
            },
            getParmsOptionInfo: function () {
                return this._paramsOptionInfo;
            },
            getScoreArr: function () {
                return this._scoreArr;
            },
            getPlayers: function () {
                return this._players;
            },
            setScoreArr: function (e) {
                for (var t = 0; t < e.length; t++) this._scoreArr[t] = e[t];
            },
            setUserLeaveVote: function (e) {
                this.leaveUserId = e.userId || 0, this.leaveVote = e.vote || 0, this.leave_close_vote = e.close_vote || 0,
                    this.leave_vote_info = e.vote_info || {}, this.leave_show_budget = e.show_budget || !1,
                    this.leave_close_vote_cd = e.close_vote_cd || 2, this.leave_vote_info_detail = e.vote_info_detail || [];
            },
            setIsShowLuckyTile: function (e) {
                this._isShowLuckyTile = e;
            },
            getIsShowLuckyTile: function () {
                return this._isShowLuckyTile;
            },
            setHasGameId: function (e) {
                this.hasGameSetGameId.gameId = e;
            },
            getHasGameId: function () {
                return this.hasGameSetGameId;
            },
            setIsTileUp: function (e) {
                this._isTileUp = e;
            },
            getIsTileUp: function () {
                return this._isTileUp;
            },
            setClickContinue: function (e) {
                this._isClickContinue = e, console.log("set this._isClickContinue", this._isClickContinue);
            },
            getClickContinue: function () {
                return console.log("get this._isClickContinue", this._isClickContinue), this._isClickContinue;
            },
            setAllowPopupRotateLuckInGameEnd: function (e) {
                this._isAllowPopupRotateLuckInGameEnd = e;
            },
            getAllowPopupRotateLuckInGameEnd: function () {
                return this._isAllowPopupRotateLuckInGameEnd;
            },
            _setAndroidGetRewardRotateLuck_Nums: function (e) {
                e >= 0 && (this._AndroidGetRewardRotateLuck_Nums = e);
            },
            _getAndroidGetRewardRotateLuck_Nums: function () {
                return this._AndroidGetRewardRotateLuck_Nums;
            },
            _setIOSGetRewardRotateLuck_Nums: function (e) {
                e >= 0 && (this._IOSGetRewardRotateLuck_Nums = e);
            },
            _getIOSGetRewardRotateLuck_Nums: function () {
                return this._IOSGetRewardRotateLuck_Nums;
            },
            getBoolShowRewardRotateLuckLayer: function () {
                var e = 0;
                return 1 == tywx.UserInfo.systemType ? Global.tableModel._getIOSGetRewardRotateLuck_Nums() > 0 && (e = Global.tableModel._getIOSGetRewardRotateLuck_Nums() - 1,
                    console.log(" 领取转运红包的次数啊啊啊啊啊啊啊 nums =", e), Global.tableModel._setIOSGetRewardRotateLuck_Nums(e),
                    !0) : Global.tableModel._getAndroidGetRewardRotateLuck_Nums() > 0 && (e = Global.tableModel._getAndroidGetRewardRotateLuck_Nums() - 1,
                    console.log(" 领取转运红包的次数啊啊啊啊啊啊啊 nums =", e), Global.tableModel._setAndroidGetRewardRotateLuck_Nums(e),
                    !0);
            },
            _setLuckRedPacket: function () {
                var e = Global.configCdn.getUISwitchConf();
                if (e && e.goodLuckNum) {
                    var t = e.goodLuckNum;
                    this._IOSGetRewardRotateLuck_Nums = t, this._AndroidGetRewardRotateLuck_Nums = t;
                } else {
                    console.error("获取CDN值失败，自己赋个值。！！！");
                    t = 2;
                    this._IOSGetRewardRotateLuck_Nums = t, this._AndroidGetRewardRotateLuck_Nums = t;
                }
            }
        },  module.exports = a
    }